package com.ygg.controller.api;

import com.ygg.model.cmn.Dict;
import com.ygg.result.Result;
import com.ygg.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api("数据字典接口")
@RestController
@RequestMapping("/api/cmn/dict")
public class DictApiController {

    @Resource
    DictService dictService;

    @ApiOperation(value = "根据dictCode获取下级节点")
    @GetMapping(value = "/findByDictCode/{dictCode}")
    public Result<List<Dict>> findByDictCode(@PathVariable String dictCode) {
        List<Dict> list = dictService.findByDictCode(dictCode);
        return Result.ok(list);
    }

    @ApiOperation(value = "根据id查询子数据列表")
    @GetMapping("findChildData/{id}")
    public Result<List<Dict>> findChildData(@PathVariable Long id) {
        return Result.ok(dictService.findChlidData(id));
    }

}
